<template>
  <div class="history-approve-flow-item">
    <el-icon class="expand" @click="fold = !fold">
      <ArrowUp v-if="fold"/>
      <ArrowDown v-else />
    </el-icon>
    <div class="node-name">
      {{ nodeInfo.name }}{{nodeInfo.describe && nodeInfo.describe !== '/' ? ('：' + nodeInfo.describe) : ''}}
    </div>
    <div class="node-type">{{ nodeInfo.time || '--'  }}</div>
    <div class="details" v-if="!fold">
      <div class="item user"><span>办理人：</span>{{ nodeInfo.person || '--'  }}</div>
      <div class="item time"><span>完成时间：</span>{{ nodeInfo.time || '--'  }}</div>
      <div class="item file" v-if="nodeInfo.exeContent?.files">
        <span>附件：</span>
        <a class="file" v-for="file in nodeInfo.exeContent.files" :href="file.resourceAddress"  target="_blank">{{ file.enclosureName }}</a>
      </div>
    </div>
  </div>
</template>

<script>
import {dicFormatter} from "@/views/construction/project-application/projectUtil";
import OrgPopoverSelect from "@/views/construction/project-application/componens/OrgPopoverSelect";

export default {
  name: "HistoryApproveFlowItem",
  components: {OrgPopoverSelect},
  props: {
    index: {
      type: Number
    },
    nodeInfo: {
      type: Object,
      default: () => ({})
    }
  },
  inject: ["options"],
  data() {
    return {
      fold: false,
      dicFormatter
    }
  },
  methods: {
    openAddApproveUser() {
      this.$refs.orgSelectRef.open({
        resolve: (checkedNodes) => {
          this.nodeInfo.approverList = checkedNodes
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.history-approve-flow-item {
  align-items: center;
  position: relative;
  padding: 0 0 20px 30px;
  border-left: 2px solid #2F7DF1;
  box-sizing: border-box;

  .expand {
    cursor: pointer;
    position: absolute;
    left: 12px;
    top: 3px;
  }

  .node-name {
    margin-right: 60px;
  }

  .node-type {
    margin-top: 10px;
    color: #a8a8a8;
    margin-right: 60px;
  }
  .details {
    display: flex;
    margin: 15px 0;
    flex-wrap: wrap;
    word-break: break-word;

    .item {
      margin-right: 20px;
      flex-wrap: wrap;
      width: 300px
    }
  }

  .file {
    display: block;
  }
}
</style>
